package com.gm.wholesale.module.order.model;

import android.util.ArrayMap;

import com.gm.commonlib.base.baseBean.BaseResp;
import com.gm.commonlib.base.baseBean.DataResp;
import com.gm.commonlib.base.baseView.IBaseView;
import com.gm.commonlib.network.BaseHttpObserver;
import com.gm.commonlib.network.HttpClient;
import com.gm.commonlib.network.HttpServicesHolder;
import com.gm.wholesale.module.order.api.IOrderApi;
import com.gm.wholesale.module.order.bean.CreateAftersaleReq;
import com.gm.wholesale.module.order.bean.CreateOrderBean;
import com.gm.wholesale.module.order.bean.OrderDetailBean;
import com.gm.wholesale.module.order.bean.OrderRecmPriceBean;
import com.gm.wholesale.module.order.bean.ReviceMoneyReq;
import com.gm.wholesale.module.order.bean.needorder.AddReceipBean;
import com.gm.wholesale.module.order.bean.needorder.NeedOrderChangeBean;
import com.gm.wholesale.module.order.bean.needorder.NeedOrderDetailBean;

import io.reactivex.Observable;

public class NeedOrderModel {
    //获取未接单数量
    public static void getUnReviceOrderSize(ArrayMap<String,Object> quearyData,
            BaseHttpObserver<DataResp<Long>> observer) {
        HttpClient.sendRequest(null, new HttpServicesHolder<IOrderApi, DataResp<Long>>() {
            @Override
            public Observable<DataResp<Long>> getHttpObservable(IOrderApi instance) {
                return instance.getUnReviceOrder(quearyData);
            }
        }, observer);
    }

    //接单
    public static void acceptOrder(long orderId,
                                   int version,
                                   IBaseView iBaseView,
                                   BaseHttpObserver<BaseResp> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IOrderApi, BaseResp>() {
            @Override
            public Observable<BaseResp> getHttpObservable(IOrderApi instance) {
                return instance.acceptOrder(orderId,version);
            }
        }, observer);
    }


    //完成分拣|截单
    public static void finishNeedOrder(long orderId,
                                       int version,
                                       IBaseView iBaseView,
                                       BaseHttpObserver<BaseResp> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IOrderApi, BaseResp>() {
            @Override
            public Observable<BaseResp> getHttpObservable(IOrderApi instance) {
                return instance.finishNeedOrder(orderId,version);
            }
        }, observer);
    }


    //知晓变更
    public static void knowOrder(long orderId,
                                 long version,
                                 IBaseView iBaseView,
                                 BaseHttpObserver<BaseResp> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IOrderApi, BaseResp>() {
            @Override
            public Observable<BaseResp> getHttpObservable(IOrderApi instance) {
                return instance.knowOrder(orderId,version);
            }
        }, observer);
    }

    //增加回执
    public static void addReceipt(long orderId,
                                  IBaseView iBaseView,
                                  AddReceipBean addReceipBean,
                                  BaseHttpObserver<BaseResp> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IOrderApi, BaseResp>() {
            @Override
            public Observable<BaseResp> getHttpObservable(IOrderApi instance) {
                return instance.addReceipt(orderId, addReceipBean);
            }
        }, observer);
    }


    //获取需求单详情
    public static void getNeedOrderDetail(long needId,
                                          IBaseView iBaseView,
                                          BaseHttpObserver<DataResp<NeedOrderDetailBean>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IOrderApi, DataResp<NeedOrderDetailBean>>() {
            @Override
            public Observable<DataResp<NeedOrderDetailBean>> getHttpObservable(IOrderApi instance) {
                return instance.getNeedOrderDetail(needId);
            }
        }, observer);
    }


    //获取变更记录
    public static void getOrderChangeInfo(long needId,
                                          IBaseView iBaseView,
                                          BaseHttpObserver<DataResp<NeedOrderChangeBean>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IOrderApi, DataResp<NeedOrderChangeBean>>() {
            @Override
            public Observable<DataResp<NeedOrderChangeBean>> getHttpObservable(IOrderApi instance) {
                return instance.getNeedOrderChange(needId);
            }
        }, observer);
    }


}
